package o;

import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import java.lang.ref.WeakReference;

public class fks<T> implements Runnable {
    private SkinAttr ˊ;
    private Handler ˋ = new Handler(Looper.getMainLooper());
    private flm<SkinAttr, T> ˎ;
    private c ˏ = c.ˊ();
    private WeakReference<Context> ॱ;

    private fks(Context context, SkinAttr o_fko, flm<SkinAttr, T> o_flm_o_fko__T) {
        this.ॱ = new WeakReference(context);
        this.ˊ = o_fko;
        this.ˎ = o_flm_o_fko__T;
    }

    public static fks ˎ(Context context, SkinAttr o_fko, flm o_flm) {
        return new fks(context, o_fko, o_flm);
    }

    public void ॱ(boolean z) {
        if (!this.ˊ.ʽ()) {
            if (z) {
                ˏ();
            } else {
                ˊ();
            }
        }
    }

    public SkinAttr ˋ() {
        return this.ˊ;
    }

    private void ˏ() {
        this.ˏ.ˊ(this);
        Object ˎ = ˎ();
        if (ˎ == null || this.ˊ.ʽ()) {
            this.ˎ.ˋ(this.ˊ, ˎ);
        } else {
            this.ˎ.ॱ(ˎ);
        }
        try {
            this.ˏ.ˎ(this);
        } catch (Throwable th) {
            fmq.ˎ("attr: " + this.ˊ.getValueRefName() + "attrValueRefName: " + this.ˊ.ˏ() + "finish() failed!" + th.getCause());
        }
    }

    private void ˊ() {
        if (this.ˎ != null) {
            this.ˎ.ˋ(this.ˊ);
        }
        this.ˏ.ˏ(this);
    }

    public void run() {
        final Object ˎ = ˎ();
        if (this.ˊ.ʽ()) {
            this.ˎ.ˋ(this.ˊ, ˎ);
        } else {
            this.ˋ.post(new Runnable(this) {
                final /* synthetic */ fks ˋ;

                public void run() {
                    if (ˎ == null) {
                        this.ˋ.ˎ.ˋ(this.ˋ.ˊ, ˎ);
                    } else {
                        this.ˋ.ˎ.ॱ(ˎ);
                    }
                }
            });
        }
        try {
            this.ˏ.ˋ(this);
        } catch (Throwable th) {
            fmq.ˎ("attr: " + this.ˊ.getValueRefName() + "attrValueRefName: " + this.ˊ.ˏ() + "finish() failed!" + th.getCause());
        }
    }

    private T ˎ() {
        if (this.ˊ.ʽ()) {
            return null;
        }
        T ˊ;
        Context context = (Context) this.ॱ.get();
        Object obj = context != null ? 1 : null;
        if (obj == null) {
            fmq.ˊ("ResFetcherCall.execute() current context had been GC! Check UI exist?");
        }
        if (obj != null) {
            ˊ = fmw.ˊ(context, this.ˊ.ˏ(), this.ˊ.getAttValueTypeName(), this.ˊ.getAttrName());
        } else {
            ˊ = null;
        }
        return ˊ;
    }
}
